//
//  CustomEventGreenView.m
//  iOSCodeLearning
//
//  Created by TFAppleWork-Summer on 2018/5/2.
//  Copyright © 2018年 Ace. All rights reserved.
//

#import "CustomEventGreenView.h"

@interface CustomEventGreenView()

@property (nonatomic, weak)  IBOutlet UIButton *btn;

@end

@implementation CustomEventGreenView
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    NSLog(@"%s",__func__);
}

// 返回谁是最适合的view
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    
    NSLog(@"%@",self.btn);
    // 当点再按钮上的时候返回按钮，不在按钮上的时候，保持系统的默认做法
    // 判断点在不在按钮身上
    // 把当前的点，转换到按钮身上的坐标系的点
    CGPoint btnP = [self convertPoint:point toView:self.btn];
    if ( [self.btn pointInside:btnP withEvent:event]) {
        return self.btn;
    }
    else{
         return [super hitTest:point withEvent:event];
    }
}

@end
